144c7b3ec5c5517b0af4fa311b42001a8e1b75bd
[lhc/web/wiklou.git] / includes / specials / SpecialWantedpages.php
1 <?php
2 /**
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 * http://www.gnu.org/copyleft/gpl.html
18 */
19
20 /**
21 * @file
22 * implements Special:Wantedpages
23 * @ingroup SpecialPage
24 */
25 class WantedPagesPage extends WantedQueryPage {
26 var $nlinks;
27
28 function WantedPagesPage( $inc = false, $nlinks = true ) {
29 $this->setListoutput( $inc );
30 $this->nlinks = $nlinks;
31 }
32
33 function getName() {
34 return 'Wantedpages';
35 }
36
37 function getSQL() {
38 global $wgWantedPagesThreshold;
39 $count = $wgWantedPagesThreshold - 1;
40 $dbr = wfGetDB( DB_SLAVE );
41 $pagelinks = $dbr->tableName( 'pagelinks' );
42 $page = $dbr->tableName( 'page' );
43 $sql = "SELECT 'Wantedpages' AS type,
44 pl_namespace AS namespace,
45 pl_title AS title,
46 COUNT(*) AS value
47 FROM $pagelinks
48 LEFT JOIN $page AS pg1
49 ON pl_namespace = pg1.page_namespace AND pl_title = pg1.page_title
50 LEFT JOIN $page AS pg2
51 ON pl_from = pg2.page_id
52 WHERE pg1.page_namespace IS NULL
53 AND pl_namespace NOT IN ( " . NS_USER . ", ". NS_USER_TALK . ")
54 AND pg2.page_namespace != " . NS_MEDIAWIKI . "
55 GROUP BY pl_namespace, pl_title
56 HAVING COUNT(*) > $count";
57
58 wfRunHooks( 'WantedPages::getSQL', array( &$this, &$sql ) );
59 return $sql;
60 }
61 }
62
63 /**
64 * constructor
65 */
66 function wfSpecialWantedpages( $par = null, $specialPage ) {
67 $inc = $specialPage->including();
68
69 if ( $inc ) {
70 @list( $limit, $nlinks ) = explode( '/', $par, 2 );
71 $limit = (int)$limit;
72 $nlinks = $nlinks === 'nlinks';
73 $offset = 0;
74 } else {
75 list( $limit, $offset ) = wfCheckLimits();
76 $nlinks = true;
77 }
78
79 $wpp = new WantedPagesPage( $inc, $nlinks );
80
81 $wpp->doQuery( $offset, $limit, !$inc );
82 }